home *** CD-ROM | disk | FTP | other *** search
/ The Guided Tour of Multimedia (Second Edition) / The Guided Tour of Multimedia (Second Edition).iso / trials / qtw111 / samples / eachpic.bas < prev    next >
BASIC Source File  |  1993-01-13  |  3KB  |  117 lines

  1. ' Require that all variables be declared
  2. Option Explicit
  3.  
  4. ' Style flag used by the Show Method
  5. Global Const MODELESS = 0
  6. Global Const MODAL = 1
  7.  
  8. ' Picture display time in milliseconds
  9. Global Const DISPLAYTIME = 8000
  10.  
  11. ' Global data
  12. Global BorderWidth As Integer     ' Width of frmEachPic border
  13. Global BorderHeight As Integer    ' Height of frmEachPic border
  14.  
  15. Global PictureCount As Integer    ' Count of Pictures in PicturePath
  16. Global PictureNum As Integer      ' Current Picture number
  17.  
  18. Global PicturePath As String      ' Path containing the Pictures
  19. Global PictureName() As String    ' Picture name array
  20.  
  21. Sub DisplayThePictures ()
  22.     Dim FileName As String      ' Current picture file name
  23.     
  24. '   Initialize the picture count data
  25.     PictureCount = 0
  26.     PictureNum = 0
  27.  
  28. '   Find the first Picture in the Picture path
  29.     FileName = Dir$(PicturePath + "\*.PIC")
  30.  
  31. '   Loop through the path to get a count of the Pictures
  32.     While (FileName <> "")
  33.         PictureCount = PictureCount + 1
  34.         FileName = Dir$
  35.     Wend
  36.  
  37. '   Let the user know if there's no Pictures in this directory,
  38. '   then end the program
  39.  
  40.     If PictureCount = 0 Then
  41.         MsgBox "There are no pictures in directory " + PicturePath, 0, "EachPic"
  42.         End
  43.     End If
  44.  
  45. '   Dimension the PictureName array depending on the number
  46. '   of Pictures in the path
  47.     ReDim PictureName(PictureCount) As String
  48.  
  49. '   One more time, get the first Picture in the path
  50.     FileName = Dir$(PicturePath + "\*.Pic")
  51.  
  52. '   Load the PictureName array with all the Picture names
  53.     While (FileName <> "")
  54.         PictureName(PictureNum) = FileName
  55.         PictureNum = PictureNum + 1
  56.         FileName = Dir$
  57.     Wend
  58.  
  59. '   Go to the first picture and show it
  60.     PictureNum = 0
  61.     ShowPicture
  62. End Sub
  63.  
  64. Sub Main ()
  65. '   Calculate the frame border width and height
  66.     BorderWidth = frmEachPic.Width - frmEachPic.ScaleWidth
  67.     BorderHeight = frmEachPic.Height - frmEachPic.ScaleHeight
  68.  
  69. '   Load the directory form
  70.     frmEachPicDir.Show MODAL
  71.  
  72. '   Load the picture form; display the pictures
  73.     Load frmEachPic
  74.     DisplayThePictures
  75. End Sub
  76.  
  77. Sub ShowPicture ()
  78. '   Frame coordinate data
  79.     Dim formLeft As Long, formTop As Long
  80.     Dim formWidth As Long, formHeight As Long
  81.  
  82. '   If the Picture number exceeds the array limit, we're done
  83.     If PictureNum >= PictureCount Then End
  84.  
  85. '   Hide the Picture form so we can adjust its size and location
  86.     frmEachPic.Hide
  87.  
  88. '   Set the Picture name from the array
  89.     frmEachPic!QTPicture1.PictureName = PicturePath + "\" + PictureName(PictureNum)
  90.  
  91. '   Calculate the frame dimensions to exactly fit the Picture
  92.     formWidth = frmEachPic!QTPicture1.Width + BorderWidth
  93.     If formWidth > Screen.Width Then formWidth = Screen.Width
  94.  
  95.     formHeight = frmEachPic!QTPicture1.Height + BorderHeight
  96.     If formHeight > Screen.Height Then formHeight = Screen.Height
  97.  
  98. '   Calculate the frame position at screen center
  99.     formLeft = (Screen.Width - formWidth) / 2
  100.     If formLeft < 0 Then formLeft = 0
  101.  
  102.     formTop = (Screen.Height - formHeight) / 2
  103.     If formTop < 0 Then formTop = 0
  104.  
  105. '   Move the frame
  106.     frmEachPic.Move formLeft, formTop, formWidth, formHeight
  107.  
  108. '   Show the Picture frame
  109.     frmEachPic.Show MODELESS
  110.  
  111. '   On the first picture, set the timer interval
  112.     If PictureNum = 0 Then
  113.         frmEachPic!tmrPicture.Interval = DISPLAYTIME
  114.     End If
  115. End Sub
  116.  
  117.